function Lbt(el){
this.el = document.querySelector(el)
this.pags = this.el.querySelectorAll('ul li')
this.num = 1
this.t = null
this.init()
}
// 方法启动
Lbt.prototype.init=function(){
this.autoplay()
this.pagover()
this.pagout()
}
// 自动轮播图
Lbt.prototype.autoplay=function(){
    this.t = setInterval(()=>{
        this.num++
    if(this.num>6)this.num=1
    this.el.querySelector('img').src = `./imgs/img${this.num}.jpg`
    this.fyq(this.num)
    },2000)
   
}
// 鼠标移入事件 获取当前图片 清除定时器 获取当前分页器
Lbt.prototype.pagover=function(){
    this.pags.forEach((item,i)=>{
        item.onmouseover=()=>{
            clearInterval(this.t)
            this.num = i+1
            this.el.querySelector('img').src = `./imgs/img${this.num}.jpg`
            this.fyq(this.num)
        }
    })


} 
// 鼠标移出事件  重启轮播图
Lbt.prototype.pagout=function(){
    this.pags.forEach((item,i)=>{
        item.onmouseout=()=>{
            this.autoplay()
        }
    })
}  
// 同步分页器
Lbt.prototype.fyq=function(num){
    this.el.querySelector('ul li.active').className = ''
    this.pags[num-1].className = 'active'

}